package com.syqc.monitor.ui.cost

import androidx.recyclerview.widget.LinearLayoutManager
import com.syqc.adapter.FeeInfoAdapter
import com.syqc.comlib.base.BaseRecycleActivity
import com.syqc.comlib.utils.GsonUtil
import com.syqc.comlib.utils.ToolbarHelper
import com.syqc.entity.AddOilFee
import com.syqc.entity.BaseFee
import com.syqc.entity.InsureFee
import com.syqc.entity.OtherFee
import com.syqc.entity.RepairFee
import com.syqc.entity.TrafficFee
import com.syqc.entity.YearVrfFee
import com.syqc.monitor.R
import com.syqc.monitor.databinding.ActivityToolbarListBinding
import com.syqc.utils.Keys

/**
 *@Author Jasper
 *@Time   2020/12/11
 *@Desc   费用详情
 */
class FeeDetailActivity :
    BaseRecycleActivity<ActivityToolbarListBinding>(ActivityToolbarListBinding::inflate) {

    override fun initView() {
        super.initView()
        val type = intent.getStringExtra(Keys.INTENT_OTHER)
        val data = intent.getStringExtra(Keys.INTENT_DATA)
        mRecyclerVB.recyclerView.layoutManager = LinearLayoutManager(this)
        initRecyclerView(type!!, data)
    }

    private fun initRecyclerView(type: String, data: String?) {
        when (type) {
            "FeeAddOil" -> {
                ToolbarHelper.setToolbar(this, R.string.desc_fee_add_oil)
                val addOilFee = GsonUtil.formObject<AddOilFee>(data)
                val mAdapter: FeeInfoAdapter<AddOilFee.InfoEntity> = FeeInfoAdapter(this, type)
                mRecyclerVB.recyclerView.adapter = mAdapter
                mAdapter.setList(addOilFee.entityList)
            }
            "FeeInsure" -> {
                ToolbarHelper.setToolbar(this, R.string.desc_fee_insure)
                val insureFee = GsonUtil.formObject<InsureFee>(data)
                val mAdapter: FeeInfoAdapter<InsureFee.InfoEntity> = FeeInfoAdapter(this, type)
                mRecyclerVB.recyclerView.adapter = mAdapter
                mAdapter.setList(insureFee.entityList)
            }
            "FeeTraffic" -> {
                ToolbarHelper.setToolbar(this, R.string.desc_fee_traffic)
                val trafficFee = GsonUtil.formObject<TrafficFee>(data)
                val mAdapter: FeeInfoAdapter<TrafficFee.InfoEntity> = FeeInfoAdapter(this, type)
                mRecyclerVB.recyclerView.adapter = mAdapter
                mAdapter.setList(trafficFee.entityList)
            }
            "FeeRepair" -> {
                ToolbarHelper.setToolbar(this, R.string.desc_fee_repair)
                val repairFee = GsonUtil.formObject<RepairFee>(data)
                val mAdapter: FeeInfoAdapter<RepairFee.InfoEntity> = FeeInfoAdapter(this, type)
                mRecyclerVB.recyclerView.adapter = mAdapter
                mAdapter.setList(repairFee.entityList)
            }
            "FeeYearVrf" -> {
                ToolbarHelper.setToolbar(this, R.string.desc_fee_year)
                val yearFee = GsonUtil.formObject<YearVrfFee>(data)
                val mAdapter: FeeInfoAdapter<BaseFee> = FeeInfoAdapter(this, type)
                mRecyclerVB.recyclerView.adapter = mAdapter
                mAdapter.setList(yearFee.entityList)

            }
            "FeeOther" -> {
                ToolbarHelper.setToolbar(this, R.string.desc_fee_other)
                val otherFee = GsonUtil.formObject<OtherFee>(data)
                val mAdapter: FeeInfoAdapter<BaseFee> = FeeInfoAdapter(this, type)
                mRecyclerVB.recyclerView.adapter = mAdapter
                mAdapter.setList(otherFee.entityList)

            }
        }
    }


    override fun setListener() {

    }
}